package com.frinder.base.akka;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * @author frinder
 * @date 2018/6/5
 * @Description: ${todo}
 */
public enum RequestType {

    NA(1);

    private int type;

    RequestType(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    static final List<RequestType> TYPES = Arrays.asList(RequestType.values());

    public static RequestType parse(final int type) {
        Optional<RequestType> op = TYPES.stream().filter(item -> type == item.getType()).findFirst();
        if (op.isPresent()) {
            return op.get();
        } else {
            return NA;
        }
    }
}
